﻿using System;
using Mono.Cecil;
using Mono.Cecil.Cil;
using ProjScan.Submodules.CS_Check;

namespace ProjScan.ScanRule.CodeAnalysis
{
	// Token: 0x02000209 RID: 521
	internal abstract class CallInstRulsImpBase : InstructionRuleImpBase
	{
		// Token: 0x06000F31 RID: 3889 RVA: 0x00043EE4 File Offset: 0x000420E4
		protected override bool AnalyzeInst(MethodDefinition method, Instruction inst, ref LineMapping failedSymbol)
		{
			bool flag = inst.OpCode == OpCodes.Call || inst.OpCode == OpCodes.Callvirt;
			bool result;
			if (flag)
			{
				MethodReference callee = (MethodReference)inst.Operand;
				bool flag2 = this.AnalyzeOperand(callee);
				if (flag2)
				{
					result = true;
				}
				else
				{
					failedSymbol.Merge(LineMapping.GetMapping(method, inst));
					result = false;
				}
			}
			else
			{
				result = true;
			}
			return result;
		}

		// Token: 0x06000F32 RID: 3890 RVA: 0x00043F50 File Offset: 0x00042150
		protected bool AnalyzeOperand(MethodReference callee)
		{
			string text = callee.Name;
			bool flag = text.StartsWith("get_");
			if (flag)
			{
				text = text.Substring("get_".Length);
			}
			bool flag2 = this.target.methods.Contains(text);
			if (flag2)
			{
				bool hasGenericParameters = callee.DeclaringType.Resolve().HasGenericParameters;
				if (hasGenericParameters)
				{
					char[] separator = new char[]
					{
						'`'
					};
					bool flag3 = this.target.types.Contains(callee.DeclaringType.Resolve().FullName.Split(separator)[0]);
					if (flag3)
					{
						return false;
					}
				}
				bool flag4 = this.target.types.Contains(callee.DeclaringType.FullName);
				if (flag4)
				{
					return false;
				}
			}
			bool flag5 = this.ruleMethodName.StartsWith("*") && this.target.types.Contains(callee.DeclaringType.Namespace);
			return !flag5;
		}

		// Token: 0x040008F0 RID: 2288
		protected string ruleMethodName;

		// Token: 0x040008F1 RID: 2289
		protected CSCheckTarget target;
	}
}
